function getChar(s){
    var n = s.length;
    var res = ''

    for (let i = 0; i < n; i++) {
        for(let j = i+1; j<=n;j++){
            let str = s.slice(i,j)
            let fin = str.split('').reverse().join('')
            if(str == fin) res = str.length>res.length?str:res

        }        
    }

    return res


}

var res = getChar('abbba')
console.log(res);


